//
// Created by livio on 2023/3/5.
//

#include "IOEvent.h"

IOEvent::IOEvent(IOEvent::Event event) : m_event{static_cast<uint8_t>(event)} {}


bool IOEvent::isRead(uint8_t event) {
    return static_cast<uint8_t>(IOEvent::Event::READ) == (event & static_cast<uint8_t>(IOEvent::Event::READ));
}

bool IOEvent::isWrite(uint8_t event) {
    return static_cast<uint8_t>(IOEvent::Event::WRITE) == (event & static_cast<uint8_t>(IOEvent::Event::WRITE));
}

bool IOEvent::isSet(const IOEvent::Event &event) const {
    return static_cast<uint8_t>(event) == (m_event & static_cast<uint8_t>(event));
}

void IOEvent::set(const IOEvent::Event &event) {
    m_event |= static_cast<uint8_t>(event);
}

void IOEvent::clear(const IOEvent::Event &event) {
    m_event &= ~static_cast<uint8_t>(event);
}
